<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>name</title>

    <!-- 引入样式 -->

    <link rel="stylesheet" href="../plugins/elementui/index.css">

    <link rel="stylesheet" href="../plugins/font-awesome/css/font-awesome.min.css">

    <link rel="stylesheet" href="../css/style.css">

</head>
<body>

<div id="app">
    <div style="margin: 20px;"><h1>账号密码修改</h1></div>
    <el-form :label-position="labelPosition" label-width="80px" :model="formLabelAlign">
        <el-form-item label="账号">
            <el-input v-model="formLabelAlign.account"></el-input>
        </el-form-item>
        <el-form-item label="密码">
            <el-input v-model="formLabelAlign.password"></el-input>
        </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer" align="center">
        <el-button type="primary" @click="modify()">提交</el-button>
    </div>
</div>

<!--引入组件库-->
<script src="../js/vue.js"></script>

<script src="../plugins/elementui/index.js"></script>

<script type="text/javascript" src="../js/jquery.min.js"></script>

<script src="../js/axios-0.18.0.js"></script>

<script>
    new Vue({
        el: "#app",
        data:{
            labelPosition: '',
            formLabelAlign: {
                uid:'',
                account: '',
                password: '',
            }
        },

        //钩子函数，VUE对象初始化完成后自动执行
        created() {
            this.getFormData();
        },

        methods:{

            //初始化表单数据
            getFormData() {
                axios.get("/network/CSRF/getSession").then((res)=>{
                    this.formLabelAlign.uid = res.data.data.uid;
                    this.formLabelAlign.account = res.data.data.account;
                    this.formLabelAlign.password = res.data.data.password;
                });
            },

            //提交表单修改账号信息
            modify() {
                axios.get("/network/CSRF/updata/"+this.formLabelAlign.account+"/"+this.formLabelAlign.password).then((res)=>{
                    if (res.data.code === 20031){
                        alert(res.data.msg);
                        this.getFormData();
                    }else {
                        this.$message.error("修改失败！！！");
                    }
                });
            }
        }
    })
</script>
</body>
</html>